Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Runner gRPC endpoint #446

Merged
merged 18 commits into from
Dec 21, 2023
Merged

feat: Runner gRPC endpoint #446

merged 18 commits into from
Dec 21, 2023

Conversation

darunrs
Copy link
Collaborator

@darunrs darunrs commented Dec 13, 2023

As part of implementing a new control plane to oversee QueryApi resources, Runner needed endpoints with which control plane can send commands. This PR adds code to create a new gRPC server with endpoints to start, stop, or list Runner executors. This provides the control plane the ability to fully control Runner, and removes the need for bilateral decision making, which was a problem of the previous design.

The changes will be changed further as needs become more concrete, closer to integration/release.

@darunrs
Copy link
Collaborator Author

darunrs commented Dec 19, 2023

Need to figure out that snyk error. I don't currently have access to view what's failing for some reason. Asking Ops.

@darunrs darunrs marked this pull request as ready for review December 19, 2023 03:23
@darunrs darunrs requested a review from a team as a code owner December 19, 2023 03:23
Copy link
Collaborator

@morgsmccauley morgsmccauley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have only skimmed the PR and have noted a few high level things.

Couple more questions:

  • How do we switch between the new/old version
  • Can you add tests?

runner/protos/runner.proto Outdated Show resolved Hide resolved
runner/src/generated/runner.ts Outdated Show resolved Hide resolved
runner/src/service/runner-service.ts Outdated Show resolved Hide resolved
runner/protos/runner.proto Outdated Show resolved Hide resolved
@darunrs
Copy link
Collaborator Author

darunrs commented Dec 19, 2023

I added tests but its under the "Load Diff". I think its hidden by default since its a bit large.

@darunrs
Copy link
Collaborator Author

darunrs commented Dec 19, 2023

Also, regarding transitioning between old and new, I'm still working on ideas for that. Do you think I should include enabling the server in this PR or not? I felt like this was already a lot and maybe I can just release the implementation and tests, and separately enable the server with a good old to new transition logic in it. What do you think?

@morgsmccauley
Copy link
Collaborator

Also, regarding transitioning between old and new, I'm still working on ideas for that. Do you think I should include enabling the server in this PR or not? I felt like this was already a lot and maybe I can just release the implementation and tests, and separately enable the server with a good old to new transition logic in it. What do you think?

Let's do it in a follow up PR to keep the work scoped. We could just create two entrypoints, and then have the main index.js file use either entrypoint based on an env flag?

runner/Dockerfile Outdated Show resolved Hide resolved
runner/package.json Outdated Show resolved Hide resolved
runner/protos/runner.proto Outdated Show resolved Hide resolved
runner/protos/runner.proto Outdated Show resolved Hide resolved
return null;
}

function validateStartExecutorRequest (request: StartExecutorRequest__Output, streamHandlers: StreamHandlers): any | null {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this manual validation? Shouldn't this be done by grpc and/or typescript?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same but when I made the client and tested just calling one of the endpoints with missing fields, it went through. The callback I got was the error I had coded myself.

runner/src/stream-handler/stream-handler.ts Show resolved Hide resolved
runner/src/service/runner-client.ts Outdated Show resolved Hide resolved
runner/src/service/index.ts Outdated Show resolved Hide resolved
@darunrs darunrs changed the title Runner endpoint feat: Runner gRPC endpoint Dec 20, 2023
Copy link
Collaborator

@morgsmccauley morgsmccauley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on this 👏🏼

Mostly looks good, left a few more minor comments. The validation still doesn't feel right, I feel like that should be implemented out of the box, can you spend some more time investigating please 🙏🏼 if we end up needing it feel free to merge 😄

runner/package.json Show resolved Hide resolved
runner/src/stream-handler/stream-handler.ts Outdated Show resolved Hide resolved
runner/src/stream-handler/worker.ts Outdated Show resolved Hide resolved
runner/src/stream-handler/stream-handler.ts Outdated Show resolved Hide resolved
@darunrs
Copy link
Collaborator Author

darunrs commented Dec 21, 2023

I'll investigate validation some more! I agree it looks awkward.

@darunrs
Copy link
Collaborator Author

darunrs commented Dec 21, 2023

There are no required fields in Protocol Buffers. Their docs state you can have an optional, repeated, or map type. I wasn't able to find any resources that indicate it's available in proto3. Apparently proto2 had it though.

@darunrs
Copy link
Collaborator Author

darunrs commented Dec 21, 2023

I think running build before test in that way causes some problems in github. Most likely its the deleting of the dist folder, since that's where the snapshots are saved. Not really sure since tsc should regenerate them. But in any case, I have to keep it as codegen && test instead of build (codegen inside) && test.

I'll commit this as is for now, and I'll improve it later if I need to. Same goes for validation.

@darunrs darunrs merged commit 38ea895 into main Dec 21, 2023
7 checks passed
@darunrs darunrs deleted the runnerEndpoint branch December 21, 2023 19:36
@darunrs darunrs linked an issue Dec 21, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose endpoint to control executors
2 participants